package vip.xiaonuo.common.caffeine;

import cn.hutool.json.JSONObject;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;
import java.util.Map;

/**
 * @author zjt
 * @description
 * @date 2025/5/21 14:39
 */
@Configuration
public class CaffeineConfig {

    @Bean
    public Cache<String, List<String>> listStrCache() {
        return Caffeine.newBuilder()
                .maximumSize(100000)
                .initialCapacity(20000)
                .build();
    }

    @Bean
    public Cache<String, Map<String, JSONObject>> userCache() {
        return Caffeine.newBuilder()
                .maximumSize(10000)
                .initialCapacity(1000)
                .build();
    }

    @Bean
    public Cache<String, Map<String, String>> mapCache() {
        return Caffeine.newBuilder()
                .maximumSize(10000)
                .initialCapacity(500)
                .build();
    }
}